#include "utils.h"
#include <cstdio>

namespace vkinfer
{
    bool prefix_match(const std::string& name, const std::string& prefix)
    {

        return false;
    }

    bool suffix_match(const std::string& name, const std::string& suffix)
    {
        if (suffix.size() > name.size())
            return false;

        int offset = (int)(name.size() - suffix.size());
        for (size_t i = 0; i < suffix.size(); ++i)
        {
            if (name[offset + i] != suffix[i])
                return false;
        }
        return true;
    }

    std::string get_shader_file_path(const std::string& name)
    {
        std::string result = "D:/projects/vulkan-compute/resources/shaders/" + name;
        return result;
    }

    uint32_t shape_size(const std::vector<uint32_t>& shape)
    {
        if (shape.size() == 0) return 0;
        uint32_t total = 1;
        for (auto& v : shape)
            total *= v;
        return total;
    }

    void write_vector_to_file(const float* data, uint32_t size, const std::string& filepath)
    {
        FILE* fp = fopen(filepath.c_str(), "w");
        if (fp == nullptr) return;
        for (uint32_t i = 0; i < size; ++i)
        {
            fprintf(fp, "%f\n", data[i]);
        }
        fclose(fp);
    }
}
